package com.itheima.mapper;

import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @className CheckGroupMapper
 */
@Mapper
public interface CheckGroupMapper {

    @Insert("insert into t_checkgroup(code, name, helpCode, sex, remark, attention) VALUES " +
            "(#{code}, #{name}, #{helpCode}, #{sex}, #{remark}, #{attention})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertCheckGroup(CheckGroup checkGroup); // 添加检查组

    void insertGroupCheckItemRelation(@Param("groupId") Integer groupId,
                                      @Param("checkItemIds") List<Integer> checkItemIds); // 检查项和检查组关联

    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{groupId}")
    void deleteGroupCheckItemRelation(Integer groupId); //删除检查项和检查组关联

    @Delete("delete from t_checkgroup where id = #{groupId}")
    void deleteCheckGroupById(Integer groupId); //根据id删除检查组

    List<CheckGroup> selectCheckGroupByPage(String queryString); //分页查询

    void updateCheckGroup(CheckGroup checkGroup); //更新检查组

    @Select("select * from t_checkgroup where id = #{groupId}")
    CheckGroup selectCheckGroupById(Integer groupId); //根据id查询检查组

    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{setMealId}")
    List<Integer> selectCheckGroupIdsBySetmealId(Integer setMealId); //根据套餐id查询检查组id

    List<CheckGroup> selectCheckGroupsByIds(@Param("checkGroupIds") List<Integer> checkGroupIds); // 根据检查组id查询检查组

    @Select("select * from t_checkgroup")
    List<CheckGroup> selectAllCheckGroup(); //查询所有检查组
}
